package com.qst.mapreduce.wordcount.diliuzhang.diyijie;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class DoubleReduce extends Reducer<Text, DoubleWritable, Text, DoubleWritable> {
    @Override
    protected void reduce(Text key, Iterable<DoubleWritable> values, Reducer<Text, DoubleWritable, Text, DoubleWritable>.Context context) throws IOException, InterruptedException {
        double tatol=0;
        int count=0;
        for (DoubleWritable value : values){

            Double mintemp=value.get();
            tatol+=mintemp;
            count++;

        }
        context.write(key, new DoubleWritable(tatol/count));
    }
}
